<?php

namespace app\api\validate;

use think\Validate;

class Trades extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'id'        => 'require|number',
        'allNo'     => 'require|regex:\w{3,30}',
        'num'       => 'require|regex:[1-9]\d*00',
        'isAuto'    => 'require',
        'price'     => 'require|number|gt:0',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'allNo.require' => '股票编号不能为空',
        'num.regex'     => '数量必须为100的倍数',
        'isAuto.require'=> '请选择是否自动管理',
        'price.number' => '购买的价格必须是一个数字',
        'price.gt'      => '购买价格需大于0'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'createStrategy' => ['allNo','num','isAuto','price'],
        'addNum'         => ['id','num'],
        'pay'         => ['id','num'],
    ];
    
}
